Skip to content

add a stopwatch around cropping pngquanting#4471

Merged
andrew-nowak merged 8 commits into
mainfrom
an/stopwatch-crop-pngquanting
Jun 12, 2025
Merged

add a stopwatch around cropping pngquanting#4471
andrew-nowak merged 8 commits into
mainfrom
an/stopwatch-crop-pngquanting

Conversation

@andrew-nowak

@andrew-nowak andrew-nowak commented Jun 9, 2025

Copy link
Copy Markdown
Member

We've had some complaints that some (pretty big & complex) pngs are being very slow to crop - eagle eyes @paperboyo noticed that we're setting output crop quality to 95 (and 75 for non-master crops), but the "quality" param have slightly different meaning for PNGs. Since they're lossless by default, lowering the quality doesn't lower the quality of the output, only the time/effort spent compressing the files. On our testing locally, this lowered the time taken to create a troublesome master crop from 30s to <1s.

While troubleshooting, I added a few new Stopwatch invocations, and created a new async variant to better track the duration of executing futures, and we also increased the pngquant speed for crops from 8 to 10 - this is the same as for image loading, and shaves a couple of extra seconds off the duration.

All told this particular image still takes 18s to crop, but this is still a marked improvement we can deliver

@github-actions

github-actions Bot commented Jun 9, 2025

Copy link
Copy Markdown

@andrew-nowak andrew-nowak force-pushed the an/stopwatch-crop-pngquanting branch from 391efd7 to f9c529c Compare June 9, 2025 15:25
@andrew-nowak andrew-nowak force-pushed the an/stopwatch-crop-pngquanting branch from 2cbcd4e to a0394b7 Compare June 9, 2025 16:48
@andrew-nowak andrew-nowak marked this pull request as ready for review June 10, 2025 10:50
@andrew-nowak andrew-nowak requested a review from a team as a code owner June 10, 2025 10:50
We don't care about filesize for master, as it'll be sent to fastly to be resized. We also don't care about non-master, as they'll be run through `pngquant` immediately after this, so any compression will be immediately undone.

@bryophyta bryophyta left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code lgtm and I tested cropping a png on TEST as well 👍👍

@prout-bot

Copy link
Copy Markdown

Seen on auth, usage, image-loader, metadata-editor, thrall, leases, cropper, collections, media-api, kahuna (merged by @andrew-nowak 8 minutes and 41 seconds ago) Please check your changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants